package src.Note.Note7;

/**
 * @Author： 20192315裴湘瑞
 * @Date: 2020/11/15 15:42
 * @Version: 1.0
 * @Target：求出数组中最大值,最小值
 * @Requirement：用循环体
 */
public class Note7 {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,2,6,3567,657,54,6,78,79,789,60,8970,92,2134,213,1234,412,34,1,45,245,465,365};
        int len = array.length;
        int max = array[0], min = array[0];
        for (int i = 0; i < len; i++) {
            if(max <= array[i]) {
                max = array[i];
            }
        }
        for (int j = 0; j < len; j++) {
            if(min >= array[j]) {
                min = array[j];
            }
        }
        System.out.println("数组长度为："+ len);
        System.out.println("最大值为：" + max);
        System.out.println("最小值为：" + min);
    }
}
